﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;

namespace SelfMadeMillionaire.Core.Entities
{
    public class SymbolOptionsHistory : BaseEntity
	{
        [StringLength(100)]
        [Required]
        public string Symbol { get; set; }
        [Required]
        public DateTime OptionDate { get; set; }
        [Required]
        public bool IsCalls { get; set; }
        [Required]
        public DateTime AddDateTime { get; set; }
        [Required]
        public double Strike { get; set; }
        [StringLength(100)]
        [Required]
        public string ContractName { get; set; }

        [Required]
        public double Last { get; set; }
        [Required]
        public double Bid { get; set; }
        [Required]
        public double Ask { get; set; }
        [Required]
        public double Change { get; set; }
        [Required]
        public double PercentChange { get; set; }
        [Required]
        public int Volume { get; set; }
        [Required]
        public int OpenInterest { get; set; }
        [Required]
        public double ImpliedVolatility { get; set; }

        public double SymbolPrice { get; set; }
        public double Probability { get; set; }

        public double BidImmediateReturn { get; set; }
        public double AskImmediateReturn { get; set; }
        public double LastImmediateReturn { get; set; }
        public double BidAnnualReturn { get; set; }
        public double AskAnnualReturn { get; set; }
        public double LastAnnualReturn { get; set; }
        public int DaysInTrade { get; set; }

        public double Discount
        {
            get
            {
                return GetDiscount();
            }
            
        }

        public double GetDiscount()
        {
            return Math.Abs(SymbolPrice - Strike) / SymbolPrice;
        }

        public double GetDiscountWhole()
        {
            return GetDiscount() * 100;
        }

        public double BidAsk2
        {
            get
            {
                return GetBidAsk2();
            }
        }

        public double GetBidAsk2()
        {
            return (BidAnnualReturn + AskAnnualReturn) / 2;
        }

        public double GetBidAsk2Whole()
        {
            return GetBidAsk2() * 100;
        }
	}
}
